﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Code.Models
{
    public enum PlayType_E
    {
        /// <summary>
        /// 前三直选
        /// </summary>
        QianSanZhiXuan = 1,
        /// <summary>
        /// 后三直选
        /// </summary>
        HouSanZhiXuan = 2,
        /// <summary>
        /// 前三组三
        /// </summary>	
        QianSanZuSan = 3,
        /// <summary>
        /// 前三组六
        /// </summary>	
        QianSanZuLiu = 4,
        /// <summary>
        /// 后三组三
        /// </summary>	
        HouSanZuSan = 5,
        /// <summary>
        /// 后三组六
        /// </summary>	
        HouSanZuLiu = 6,
        /// <summary>
        /// 前三值和
        /// </summary>	
        QianSanZhiHe = 7,
        /// <summary>
        /// 后三值和
        /// </summary>	
        HouSanZhiHe = 8,
        /// <summary>
        /// 前三组和
        /// </summary>	
        QianSanZuHe = 9,
        /// <summary>
        /// 后三组和
        /// </summary>	
        HouSanZuHe = 10,
        /// <summary>
        /// 前二
        /// </summary>	
        Qianer = 11,
        /// <summary>
        /// 后二
        /// </summary>	
        Houer = 12,
        /// <summary>
        /// 大小单双
        /// </summary>	
        DaXiaoDanShuan = 13,
        /// <summary>
        /// 定位胆
        /// </summary>	
        DingWeiDan = 14,
        /// <summary>
        /// 不定位胆
        /// </summary>	
        BuDingWeiDan = 15,
        /// <summary>
        /// 前三不定位胆
        /// </summary>	
        QianSanBuDingWeiDan = 16,
        /// <summary>
        /// 后三不定位胆
        /// </summary>	
        HouSanBuDingWeiDan = 17,
        /// <summary>
        /// 直选
        /// </summary>	
        ZhiXuan = 18,
        /// <summary>
        /// 组三
        /// </summary>	
        ZuSan = 19,
        /// <summary>
        /// 组六
        /// </summary>	
        ZuLiu = 20,
        /// <summary>
        /// 值和
        /// </summary>	
        ZhiHe = 21,
        /// <summary>
        /// 组和
        /// </summary>	
        ZuHe = 22,
        /// <summary>
        /// 前二直选
        /// </summary>	
        QianerZhiXuan = 23,
        /// <summary>
        /// 前二组选
        /// </summary>	
        QianerZuXuan = 24,
        /// <summary>
        /// 任选1
        /// </summary>	
        Chose1 = 25,
        /// <summary>
        /// 任选2
        /// </summary>	
        Chose2 = 26,
        /// <summary>
        /// 任选3
        /// </summary>	
        Chose3 = 27,
        /// <summary>
        /// 任选4
        /// </summary>	
        Chose4 = 28,
        /// <summary>
        /// 任选5
        /// </summary>	
        Chose5 = 29,
        /// <summary>
        /// 任选6
        /// </summary>	
        Chose6 = 30,
        /// <summary>
        /// 任选7
        /// </summary>	
        Chose7 = 31,
        /// <summary>
        /// 任选8
        /// </summary>	
        Chose8 = 32,
        /// <summary>
        /// 11选5 前三组选
        /// </summary>
        TCQianSanZuXuan = 33,
        /// <summary>
        /// 11选5 前三直选
        /// </summary>
        TCQianSanZhiXuan = 34,
        /// <summary>
        /// 数字
        /// </summary>
        Number=35,
        /// <summary>
        /// 生肖
        /// </summary>	
        Animals = 36,
        /// <summary>
        /// 季节
        /// </summary>	
        Season = 37,
        /// <summary>
        /// 方位
        /// </summary>	
        Position = 38,
        /// <summary>
        /// 北京快乐8-快乐选号玩法
        /// </summary>
        ChoseNum= 39,
        /// <summary>
        /// 北京快乐8-和值玩法
        /// </summary>	
        HeZhi = 40,
        /// <summary>
        /// 北京快乐8-龙虎玩法
        /// </summary>
        LongFu=41,



        /// <summary>
        /// 直选和值
        /// </summary>	
        ZhiXuanHeZhi = 111,
       
        /// <summary>
        /// 组选和值
        /// </summary>	
        ZuXuanHeZhi = 112,
        /// <summary>
        /// 个位和值
        /// </summary>	
        GeWeiHeZhi = 113,
        /// <summary>
        /// 前一
        /// </summary>	
        QianYi = 117,
        /// <summary>
        /// 后一
        /// </summary>	
        HouYi = 118,
        /// <summary>
        /// 合值
        /// </summary>	
        SumValue = 125,
        QianSanZuXuan,
        ZuXuan, HouSanZuXuan, QianSanDingWeiDan, HouSanDingWeiDan,

        /// <summary>
        /// 任二胆拖
        /// </summary>
        RenErDanTuo=48,
        /// <summary>
        /// 任三胆拖
        /// </summary>
        RenSanDanTuo = 49,
        /// <summary>
        /// 任四胆拖
        /// </summary>
        RenSiDanTuo = 50,
        /// <summary>
        /// 任五胆拖
        /// </summary>
        RenWuDanTuo = 51,
        /// <summary>
        /// 前一数投
        /// </summary>
        QianYiShuTou=53,
        /// <summary>
        /// 前一红投
        /// </summary>
        QianYiHongTou=54,
        /// <summary>
        /// 选二连值
        /// </summary>
        XuanErLianZhi=56,
        /// <summary>
        /// 选三前值
        /// </summary>
        XuanSanQianZhi= 57,

        /// <summary>
        /// 选二连组
        /// </summary>
        XuanErLianZu=59,
        /// <summary>
        /// 选三前组
        /// </summary>
        XuanSanQianZu = 60,

        /// <summary>
        /// 选二连组胆拖
        /// </summary>
       XuanErLianZuDanTuo=61,
       /// <summary>
       /// 选三前组胆拖
       /// </summary>
       XuanSanQianZuDanTuo = 62,

        /// <summary>
        /// 任选二
        /// </summary>
         RenXuanEr=43,
         /// <summary>
         /// 任选三
         /// </summary>
         RenXuanSan = 44,
         /// <summary>
         /// 任选四
         /// </summary>
         RenXuanSi = 45,
         /// <summary>
         /// 任选五
         /// </summary>
         RenXuanWu = 46,


    }
    public static class PlayTypeEx
    {
        public static string GetName(this PlayType_E type)
        {
            switch (type)
            {
                case PlayType_E.QianSanZhiXuan:
                    return "前三直选";
                case PlayType_E.HouSanZhiXuan:
                    return "后三直选";
                case PlayType_E.QianSanZuSan:
                    return "前三组三";
                case PlayType_E.QianSanZuLiu:
                    return "前三组六";
                case PlayType_E.HouSanZuSan:
                    return "后三组三";
                case PlayType_E.HouSanZuLiu:
                    return "后三组六";
                case PlayType_E.QianSanZhiHe:
                    return "前三值和";
                case PlayType_E.HouSanZhiHe:
                    return "后三值和";
                case PlayType_E.QianSanZuHe:
                    return "前三组和";
                case PlayType_E.TCQianSanZhiXuan:
                    return "前三直选";
                case PlayType_E.TCQianSanZuXuan:
                    return "前三组选";
                case PlayType_E.QianerZhiXuan:
                    return "前二直选";
                case PlayType_E.QianerZuXuan:
                    return "前二组选";
                case PlayType_E.HouSanZuHe:
                    return "后三组和";
                case PlayType_E.Qianer:
                    return "前二";
                case PlayType_E.Houer:
                    return "后二";
                case PlayType_E.DaXiaoDanShuan:
                    return "大小单双";
                case PlayType_E.DingWeiDan:
                    return "定位胆";
                case PlayType_E.BuDingWeiDan:
                    return "不定位胆";
                case PlayType_E.QianSanBuDingWeiDan:
                    return "前三不定位胆";
                case PlayType_E.HouSanBuDingWeiDan:
                    return "后三不定位胆";
                case PlayType_E.ZhiXuan:
                    return "直选";
                case PlayType_E.ZuSan:
                    return "组三";
                case PlayType_E.ZuLiu:
                    return "组六";
                case PlayType_E.ZhiHe:
                    return "值和";
                case PlayType_E.ZuHe:
                    return "组和";
                case PlayType_E.ZhiXuanHeZhi:
                    return "直选和值";
                case PlayType_E.ZuXuanHeZhi:
                    return "组选和值";
                case PlayType_E.GeWeiHeZhi:
                    return "个位和值";
                case PlayType_E.QianYi:
                    return "前一";
                case PlayType_E.HouYi:
                    return "后一";
                case PlayType_E.SumValue:
                    return "合值";
                case PlayType_E.Chose1:
                    return "任选1";
                case PlayType_E.Chose2:
                    return "任选2";
                case PlayType_E.Chose3:
                    return "任选3";
                case PlayType_E.Chose4:
                    return "任选4";
                case PlayType_E.Chose5:
                    return "任选5";
                case PlayType_E.Chose6:
                    return "任选6";
                case PlayType_E.Chose7:
                    return "任选7";
                case PlayType_E.Chose8:
                    return "任选8";
                case PlayType_E.Number:
                    return "数字";
                case PlayType_E.Animals:
                    return "生肖";
                case PlayType_E.Season:
                    return "季节";
                case PlayType_E.Position:
                    return "方位";
                case PlayType_E.ChoseNum:
                    return "快乐选号";
                case PlayType_E.HeZhi:
                    return "和值";
                case PlayType_E.RenXuanEr:
                    return "任选二";
                case PlayType_E.RenXuanSan:
                    return "任选三";
                case PlayType_E.RenXuanSi:
                    return "任选四";
                case PlayType_E.RenXuanWu:
                    return "任选五";
                case PlayType_E.RenErDanTuo:
                    return "任二胆拖";
                case PlayType_E.RenSanDanTuo:
                    return "任三胆拖";
                case PlayType_E.RenSiDanTuo:
                    return "任四胆拖";
                case PlayType_E.RenWuDanTuo:
                    return "任五胆拖";
                case PlayType_E.QianYiShuTou:
                    return "前一数投";
                case PlayType_E.QianYiHongTou:
                    return "前一红投";
                case PlayType_E.XuanErLianZhi:
                    return "选二连直";
                case PlayType_E.XuanErLianZu:
                    return "选二连组";
                case PlayType_E.XuanSanQianZu:
                    return "选三前组";
                case PlayType_E.XuanErLianZuDanTuo:
                    return "选二连组胆拖";
                case PlayType_E.XuanSanQianZuDanTuo:
                    return "选三前组胆拖";
                case PlayType_E.XuanSanQianZhi:
                    return "选三前直";


                default:
                    return type.ToString();
            }
        }
        public static string GetOpenCode(this PlayType_E type, string openCode, LotteryType lotteryType)
        {
            if (string.IsNullOrEmpty(openCode))
            {
                throw new ArgumentNullException("openCode");
            }
            try
            {
                switch (lotteryType)
                {
                    #region HLJSSC JXSSC CQSSC
                    case LotteryType.HLJSSC:
                    case LotteryType.JXSSC:
                    case LotteryType.CQSSC:
                    case LotteryType.XJSSC:
                        switch (type)
                        {
                            case PlayType_E.QianYi:
                                return openCode.Substring(0, 1);
                            case PlayType_E.HouYi:
                                return openCode.Substring(openCode.Length - 1);
                            case PlayType_E.Qianer:
                                return openCode.Substring(0, 2);
                            case PlayType_E.Houer:
                            case PlayType_E.DaXiaoDanShuan:
                                return openCode.Substring(openCode.Length - 2);
                            case PlayType_E.QianSanZhiXuan:
                            case PlayType_E.QianSanZhiHe:
                            case PlayType_E.QianSanZuHe:
                            case PlayType_E.QianSanBuDingWeiDan:
                            case PlayType_E.QianSanZuSan:
                            case PlayType_E.QianSanZuLiu:
                                return openCode.Substring(0, 3);
                            case PlayType_E.HouSanZhiXuan:
                            case PlayType_E.HouSanZuXuan:
                            case PlayType_E.HouSanBuDingWeiDan:
                            case PlayType_E.HouSanDingWeiDan:
                            case PlayType_E.HouSanZuHe:
                            case PlayType_E.HouSanZhiHe:
                            case PlayType_E.HouSanZuSan:
                            case PlayType_E.HouSanZuLiu:
                                return openCode.Substring(openCode.Length - 3);
                            case PlayType_E.DingWeiDan:
                                return openCode;
                            default:
                                throw new ArgumentException("当前彩种找不到此玩法。");
                        }
                    #endregion

                    #region SHSSC FC3D SZPL
                    case LotteryType.SHSSL:
                    case LotteryType.FC3D:
                    case LotteryType.SZPL:
                        switch (type)
                        {
                            case Code.Models.PlayType_E.ZhiXuan:
                            case Code.Models.PlayType_E.ZuLiu:
                            case Code.Models.PlayType_E.ZuSan:
                            case Code.Models.PlayType_E.ZhiHe:
                            case Code.Models.PlayType_E.ZuHe:
                            case Code.Models.PlayType_E.HouSanBuDingWeiDan:
                            case Code.Models.PlayType_E.HouSanDingWeiDan:
                                return openCode;
                            case Code.Models.PlayType_E.Qianer:
                                return openCode.Substring(0, 2);
                            case Code.Models.PlayType_E.Houer:
                                return openCode.Substring(openCode.Length - 2);
                            //case Code.Models.PlayType_E.SanXingHeZhi:
                            //    return openCode;
                            default:
                                throw new ArgumentException("当前彩种找不到此玩法。");
                        }
                    #endregion

                    #region TC11X5
                    case LotteryType.TC11X5:
                        switch (type)
                        {
                            case PlayType_E.TCQianSanZhiXuan:
                            case PlayType_E.TCQianSanZuXuan:
                                return string.Join(",", openCode.Split(',').Take(3).ToArray());
                            case PlayType_E.QianerZhiXuan:
                            case PlayType_E.QianerZuXuan:
                                return string.Join(",", openCode.Split(',').Take(2).ToArray());
                            case PlayType_E.Chose1:
                                return openCode.Split(',')[0];
                            case PlayType_E.Chose2:
                            case PlayType_E.Chose3:
                            case PlayType_E.Chose4:
                            case PlayType_E.Chose5:
                            case PlayType_E.Chose6:
                            case PlayType_E.Chose7:
                            case PlayType_E.Chose8:
                                return openCode;
                            default:
                                throw new ArgumentException("当前彩种找不到此玩法。");
                        }
                    #endregion

                    #region HC1
                    case LotteryType.HaoCai1:
                        switch (type)
                        {
                            case PlayType_E.Number:
                            case PlayType_E.Animals:
                            case PlayType_E.Season:
                            case PlayType_E.Position:
                                return openCode.Split(',')[0];
                            default:
                                throw new Exception("好彩彩种无当前玩法!");
                        }
                    #endregion

                    #region 北京快乐8
                    case LotteryType.BJKL8:
                        switch (type)
                        { 
                            case PlayType_E.ChoseNum:
                            case PlayType_E.HeZhi:
                            case PlayType_E.LongFu:
                                return openCode;
                            default:
                                throw new Exception("北京快乐8暂无当前玩法");
                        }
                    #endregion

                    #region 勿删
                    //case LotteryType.TCP3:
                    //    switch (type)
                    //    {
                    //        case Code.Models.PlayType_E.ZhiShuan:
                    //            return   openCode;
                    //        case Code.Models.PlayType_E.ZuShuan:
                    //            return   openCode;
                    //        case Code.Models.PlayType_E.ZhiShuanHeZhi:
                    //            return    "";
                    //        case Code.Models.PlayType_E.ZuShuanHeZhi:
                    //            return    "";
                    //        case Code.Models.PlayType_E.HouSanBuDingWeiDan:
                    //            return    openCode.Substring(openCode.Length - 3);
                    //        case Code.Models.PlayType_E.QianYi:
                    //            return    openCode.Substring(0, 1);
                    //        case Code.Models.PlayType_E.HouYi:
                    //            return    openCode.Substring(openCode.Length - 1);
                    //        case Code.Models.PlayType_E.Qianer:
                    //            return    openCode.Substring(0, 2);
                    //        case Code.Models.PlayType_E.Houer:
                    //            return    openCode.Substring(openCode.Length - 2);
                    //        default:
                    //            throw new Exception("P3彩种没有当前玩法!");
                    //    }
                    //case LotteryType.SYRDJ:
                    //    switch (type)
                    //    {
                    //        case Code.Models.PlayType_E.QianSanZhiShuan:
                    //            return  openCode.Substring(0, 3);
                    //        case Code.Models.PlayType_E.QianSanZuShuan:
                    //            return  openCode.Substring(0, 3);
                    //        case Code.Models.PlayType_E.QianerZhiShuan:
                    //            return  openCode.Substring(0, 2);
                    //        case Code.Models.PlayType_E.QianerZuShuan:
                    //            return  openCode.Substring(0, 2);
                    //        case Code.Models.PlayType_E.Chose1:
                    //            return  openCode;
                    //        case Code.Models.PlayType_E.Chose2:
                    //            return  openCode;
                    //        case Code.Models.PlayType_E.Chose3:
                    //            return  openCode;
                    //        case Code.Models.PlayType_E.Chose4:
                    //            return  openCode;
                    //        case Code.Models.PlayType_E.Chose5:
                    //            return  openCode;
                    //        case Code.Models.PlayType_E.Chose6:
                    //            return  openCode;
                    //        case Code.Models.PlayType_E.Chose7:
                    //            return  openCode;
                    //        case Code.Models.PlayType_E.Chose8:
                    //            return  openCode;
                    //        default:
                    //            throw new Exception("十一运夺金没有当前彩种!");
                    //    }
                    #endregion

                    #region 广东快乐十分
                    case LotteryType.GDKLSF:
                        switch (type) 
                        {

                            case PlayType_E.RenXuanEr:
                            case PlayType_E.RenXuanSan:
                            case PlayType_E.RenXuanSi:
                            case PlayType_E.RenXuanWu:
                            case PlayType_E.RenErDanTuo:
                            case PlayType_E.RenSanDanTuo:
                            case PlayType_E.RenSiDanTuo:
                            case PlayType_E.RenWuDanTuo:
                            case PlayType_E.XuanErLianZu:
                            case PlayType_E.XuanSanQianZu:
                            case PlayType_E.XuanErLianZuDanTuo:
                            case PlayType_E.XuanSanQianZuDanTuo:
                            case PlayType_E.QianYiShuTou:
                            case PlayType_E.QianYiHongTou:
                            case PlayType_E.XuanErLianZhi:
                           
                                return openCode;
                            default:
                                throw new Exception("广东快乐十分暂无当前玩法");
                        
                        }
                    #endregion
                    default:
                        return openCode;
                }
            }
            catch (ArgumentException e)
            {
                throw e;
            }
            catch (Exception)
            {
                throw new Exception("开奖号码格式不正确！");
            }
        }
    }
}
